package com.niiwoo.civet.mobile.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.niiwoo.civet.account.dto.response.AccountCompanyDTO;
import com.niiwoo.civet.account.enums.AccountCompanyAccountTypeEnum;
import com.niiwoo.civet.account.service.AccountCompanyDubboService;
import com.niiwoo.civet.mobile.vo.response.CompanyRegisterProcessResponseVO;
import com.niiwoo.tripod.web.annotation.AuthIgnore;
import com.niiwoo.tripod.web.util.PrincipalContext;
import com.niiwoo.tripod.web.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/company")
@Api(tags = "企业存管注册", description = "/company")
public class CompanyRegisterController {

    @Reference(version="1.0.0")
    private AccountCompanyDubboService accountCompanyDubboService;

    @PostMapping("/companyRegisterProcess")
    @ApiOperation("企业存管注册流程查询")
    public Result<CompanyRegisterProcessResponseVO> getCompanyRegisterProcess(String orgId){
        String userId = PrincipalContext.getUserId();
        log.info("企业存管注册流程查询:userId={},orgId={}",userId,orgId);
        AccountCompanyDTO accountCompanyDTO = accountCompanyDubboService.queryAccountCompanyByUserIdAndOrgIdWithAccountType(userId,orgId, AccountCompanyAccountTypeEnum.INVEST_ORG.getType());
        CompanyRegisterProcessResponseVO vo = new CompanyRegisterProcessResponseVO();
        if(accountCompanyDTO != null) {
            vo.setAuditStatus(accountCompanyDTO.getAuditStatus());
            vo.setRegister(true);
        }else{
            vo.setRegister(false);
        }
        return Result.with(vo);
    }
}
